public class MyQueue {
    class Node{
        int val;
        Node next;
        public Node(int data){
            val=data;
        }
    }
    Node head;
    Node last;
    int usedSize;
    public void offer(int data){
        Node node=new Node(data);
        if(head==null){
            head=node;
            last=node;
        } else{
            last.next=node;
            last=node;
        }
        usedSize++;
    }
    public int poll(){
        if(isEmpty()){
            throw new EmptyExpection("队列是空的");
        }
       int ret=head.val;
        head=head.next;
        usedSize--;
        return ret;
    }

    public int peek(){
        if(isEmpty()){
            throw new EmptyExpection("队列是空的");
        }
      return head.val;
    }
    private boolean isEmpty(){
        if(usedSize==0){
            return true;
        }
        return false;
    }
}
